/**
 * webpack与server相关配置
 */

const path = require('path');
const name = "管理系统";

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    lintOnSave: false,
    devServer: {
        proxy: {
            '/ws': {
                target: 'ws://192.168.13.20:4001',
                ws: true,
                changeOrigin: true
            },
            '/screen': {
                target: 'http://192.168.13.20:3001',
                changeOrigin: true,
            }
        }
    },
    configureWebpack: {
        // provide the app's title in webpack's name field, so that
        // it can be accessed in index.html to inject the correct title.
        name: name,
        resolve: {
            alias: {
                '@': resolve('src')
            }
        }
    },
    chainWebpack: config => {
        config.plugin('html').tap(args => {
            args[0].title = name
            return args
        });
        config.plugins.delete('preload');
        config.plugins.delete('prefetch');
        config.when(process.env.NODE_ENV === 'development',
            config.devtool('cheap-module-eval-source-map')
        )
    }
};